<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
  <head>
    <title>index.html</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/back/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/back/js/jquery-3.3.1.js"></script>
	<script src="${pageContext.request.contextPath}/back/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/back/css/btn.css" />
    <meta charset="utf-8">
    
	<style type="text/css">
		table {
			border-right: 1px solid black;
			border-bottom: 1px solid black;
		}
		
		table td {
			padding: 10px;
			text-align:center;
			border-left: 1px solid black;
			border-top: 1px solid black;
		}
</style>
  </head>
  
  <body style="background-color: #f0f9fd;">
  	
  	<div align=center style="font-size:25px">图书管理</div><hr/>  	
  	<div style="margin: 0 auto;text-align:center;">
  		<form action="${pageContext.request.contextPath}/book/selectAllBookByPages" method="post">
  			<input onclick="location.href='${pageContext.request.contextPath}/book/toAddBook'" class="button btn-p" value="添加图书&raquo;" />&emsp;&emsp;
		  	<select name="key" class="el-select__inner inner2">
		  		<option value="name">书名</option>
		  		<option value="author">作者</option>
		  		<option value="press">出版社</option>
		  	</select>
		  	<input class="el-input__inner" type="text" placeholder="请输入查询条件" name="content"/>
		  	<input class="el-search-content" type="submit" value="搜索"/>
	  	</form>
  	</div>
  	<div style="margin-top:20px">
  	<table bordercolor='#898E90' align='center' border='3px' cellpadding='5px' cellspacing="0px" >
  		<tr bgcolor='lightblue' align='center'>
			<td style="width: 100px">名称</td>
			<td>作者</td>
			<td>定价</td>
			<td>当当价</td>
			<td>出版社</td>
			<td>出版时间</td>
			<td>封面图</td>
			<td>销量</td>
			<td>库存</td>
			<td>操作</td>
  		</tr>

		<c:forEach var="book" items="${requestScope.pageInfo.list}">
			<tr align='center'>
				<td>${book.bookName}</td>
				<td>${book.author}</td>
				<td>${book.price}</td>
				<td>${book.dprice}</td>
				<td>${book.press}</td>
				<td><fmt:formatDate value="${book.pressDate}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
				<td>
					<img width="32px" height="20px" src="${pageContext.request.contextPath}/back/img/${book.cover}" >
				</td>
				<td>${book.sale}</td>
				<td>${book.stock}</td>
				<td>
					<input  class="button"  onclick="location.href='${pageContext.request.contextPath}/book/toUpdateBook?bookId=${book.bookId}&pageNum=${pageInfo.pageNum}&key=${requestScope.key}&content=${requestScope.content}'" value="修改 " />
					<input class="button-del" onclick="location.href='${pageContext.request.contextPath}/book/deleteBook?bookId=${book.bookId}&pageNum=${pageInfo.pageNum}&key=${requestScope.key}&content=${requestScope.content}'" value="删除 " />
				</td>
			</tr>
		</c:forEach>
  	</table>
  	</div><br>
  	<div align="center">
		<span style="font-size: 25px;margin: 5px">
			当前第${pageInfo.pageNum}页,共${pageInfo.pages}页,总${pageInfo.total}条记录
		</span>
		<nav aria-label="Page navigation">
			<ul class="pagination">
				<li><a href="${pageContext.request.contextPath}/book/selectAllBookByPages?pageNum=1&key=${requestScope.key}&content=${requestScope.content}">首页</a></li>
				<li>
					<a href="${pageContext.request.contextPath}/book/selectAllBookByPages?pageNum=${pageInfo.prePage}&key=${requestScope.key}&content=${requestScope.content}" aria-label="Previous">
						<span aria-hidden="true">&laquo;</span>
					</a>
				</li>
				<c:forEach items="${pageInfo.navigatepageNums}" var="page_Num">
					<c:if test="${page_Num==pageInfo.pageNum}">
						<li class="active"><a href="${pageContext.request.contextPath}/book/selectAllBookByPages?pageNum=${page_Num}&key=${requestScope.key}&content=${requestScope.content}">${page_Num}</a></li>
					</c:if>
					<c:if test="${page_Num!=pageInfo.pageNum}">
						<li><a href="${pageContext.request.contextPath}/book/selectAllBookByPages?pageNum=${page_Num}&key=${requestScope.key}&content=${requestScope.content}">${page_Num}</a></li>
					</c:if>
				</c:forEach>
				<li>
					<a href="${pageContext.request.contextPath}/book/selectAllBookByPages?pageNum=${pageInfo.pageNum+1}&key=${requestScope.key}&content=${requestScope.content}" aria-label="Next">
						<span aria-hidden="true">&raquo;</span>
					</a>
				</li>
				<li><a href="${pageContext.request.contextPath}/book/selectAllBookByPages?pageNum=${pageInfo.pages}&key=${requestScope.key}&content=${requestScope.content}">尾页</a></li>
			</ul>
		</nav>
	</div>

  <script>
	  var a='${param.message}';
	  if(a!=null&&a.length>0){
		  alert('${param.message}');
	  }
  </script>
  </body>
</html>
